package com.szm.userserver.webui;

import com.szm.userserver.entity.User;
import com.szm.userserver.service.UserRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/userredis")
public class UserRedisController {

    @Autowired
    private UserRedisService userRedisService;

    @RequestMapping("/getuser/{username}")
    public String getUser(@PathVariable String username){
       return userRedisService.getUser(username);
    }

    @RequestMapping("/setuser")
    public String setUser(){
        User user=new User();
        user.setId(1);
        user.setUsername("szm");
        userRedisService.setUser(user);
        return  "setuser success";
    }

    @RequestMapping("/deluser/{username}")
    public String delUser(@PathVariable String username){
        userRedisService.delUser(username);
        return  "deluser success";
    }

    @RequestMapping("/getobj/{object}")
    public Object getObj(@PathVariable Object object){
        Object obj= userRedisService.getObj(object);
        return  obj;
    }
}
